<include file="Index/_meta" />
<body>
<style>
    .box{
        margin-top: 20px;
        margin-left: 20px;
        box-shadow: none;
    }
    .sum{
        float: right;
        margin-right: 20px;
        line-height: 32px;
    }
    .quanxian{
        display: inline-block;
        width: 200px;
    }
    .addquanxian{
        display: inline-block;
        float: left;
    }
    .juzhong{
        width: 270px;
        margin: 0 auto;
    }
    .refresh{
        display: inline-block;
        float: right;
        margin-right: 20px;
    }
</style>
<div class="box">
    <button class="layui-btn layui-btn-normal addquanxian">添加文章</button>
    <button class="layui-btn layui-btn-normal refresh" onclick="refresh()" title="刷新"><i class="layui-icon">&#x1002;</i></button>
    <div class="layui-input-block juzhong">
        <input type="text" name="title" autocomplete="off" placeholder="请输入文章标题" class="layui-input quanxian">
        <button class="layui-btn layui-btn-normal"><i class="layui-icon">&#xe615;</i></button>
    </div>

    <!--<span class="sum">共有数据：<strong>{$count|default=0}</strong> 条</span>-->
</div><br>
<div class="layui-fluid">
    <fieldset class="layui-elem-field">
        <legend>请选择首页的内容</legend>
        <div class="layui-field-box">
            <form class="layui-form" action="">
                <div class="layui-form-item">
                    <label class="layui-form-label"></label>
                    <div class="layui-input-block">
                        <?php foreach($data as $k=>$v){?>
                        <?php if(in_array($v[id],$shouid)){
                            $check = 'checked';}else{
                            $check = '';
                            }?>
                        <input type="checkbox" value="<?php echo $v['id']?>" <?php echo $check;?> title="<?php echo $v['name']?>">
                        <?php }?>
                    </div>
                </div>

                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button type="button" id="tijiao" class="layui-btn layui-btn-normal">立即提交</button>
                    </div>
                </div>
            </form>
        </div>
    </fieldset>
</div>

<script type="text/javascript">
    layui.use(['layer',['form']],function () {
        var layer = layui.layer;
        var form = layui.form;

        var url = '/index.php/home/set/updateData';
        $('#tijiao').click(function () {
            var id = $(':checkbox:checked');
            var ids = '';
            for(var i = 0;i<id.length;i++){
                ids += id[i].value+','
            }
            ids = ids.substring(0,ids.length-1);  //去掉最后的逗号
            var data = {ids:ids};
            $.post(url,data,function (data) {
                if(data.status=='1'){
                    layer.msg(data.message);
                    setTimeout(function () {
                        window.parent.location.replace(window.parent.location.href);
                    },1000);
                }
            },"jSON");
        })
    });

</script>

</body>